package newDecoupling.controller;


import jakarta.annotation.Resource;
import newDecoupling.projo.Hero;
import newDecoupling.service.HeroService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

//@Component
@RestController
public class HeroController {

//    @Qualifier("userServiceImpl")
//    @Resource(name = "userServiceImpl2")
//    方式一  属性注入
//    @Autowired
//    private HeroService heroService;
//     方式二  构造器注入
//    public HeroController(HeroService heroService) {
//        this.heroService = heroService;
//    }
//    方式三  setter注入
//    private HeroService heroService;
//    @Autowired
//    public void setHeroService(HeroService heroService) {
//        this.heroService = heroService;
//    }

//    @Qualifier("heroServiceImpl2")
    @Autowired
    @Resource(name = "heroServiceImpl2")
    private HeroService heroService;


    @RequestMapping("/hero")
    public List<Hero> getHero()
    {
        List<Hero> heroes = heroService.selectList();
        return heroes;
    }


}
